<?php
$profileId=$_SESSION['profileid'];
if(isset($_GET['date3']))
{
	$startDate = $_GET['date3'];
} else {
	$tanggalmulai= date('Y-m-d', strtotime('-1 month'));
	$startDate = $tanggalmulai;
}
if(isset($_GET['date4']))
{
	$endDate = $_GET['date4'];
} else {
$endDate = date('Y-m-d');
}
if(isset($_GET['dimension']))
{
	$dimension = $_GET['dimension'];
} else {
$dimension = "ga:date";
}

?>
<h2 align = "center">Peak Activity</h2>
<div class = "row" >
<?php
$SHParams = array(
      'dimensions' => 'ga:hour',
      
      'sort' => '-ga:sessions');
$resultsSH = $analytics->data_ga->get(
       'ga:' . $profileId,
       $startDate,
       $endDate,
	   'ga:sessions',
       $SHParams
	   );
?>
<script type="text/javascript">
            var chartDataSH = [
		<?php
    // Print table rows.
		$x=1;
		foreach ($resultsSH->getRows() as $row) {
      
		?>
		{
			"hour": "<?php echo $row[0]; ?>",
			"visits": <?php echo $row[1]; ?>
		}
		<?php
		if($x>=sizeof($resultsSH->getRows()))
		{
		?>
		<?php
		}
		else
		{
		?>
		,
		<?php
		}
		$x++;
     
		}
		?>
		];
</script>

</div>	   


<script src="amcharts/amcharts.js" type="text/javascript"></script>
  <script src="amcharts/pie.js" type="text/javascript"></script>

        <script type="text/javascript">
            var chartSH;

            AmCharts.ready(function () {
                // PIE CHART
                chartSH = new AmCharts.AmPieChart();
                chartSH.dataProvider = chartDataSH;
                chartSH.titleField = "hour";
                chartSH.valueField = "visits";
                chartSH.outlineColor = "#FFFFFF";
                chartSH.outlineAlpha = 0.8;
                chartSH.outlineThickness = 2;
                chartSH.balloonText = "";
                // this makes the chartSH 3D
                chartSH.depth3D = 15;
                chartSH.angle = 30;

                // WRITE
                chartSH.write("chartSH");
            });
        </script>


<div class = "row" >

<div id="chartSH" style="width: 100%; height: 400px;"></div>
</div>
